{include file="admin/public/head"}

<form class="layui-form" style="padding: 20px 70px 0 0;">
    <div class="layui-form-item">
        <label class="layui-form-label">父级</label>
        <div class="layui-input-block">
            <select name="pid" lay-verify="required" lay-search="">
                <option value="0">顶级菜单</option>
                {volist name="$menu" id="v"}
                <option value="{$v.id}">{$v.str}{$v.title}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">链接</label>
        <div class="layui-input-block">
            <input type="text" name="src" placeholder="请输入链接" autocomplete="off" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block">
            <input type="checkbox" name="is_menu" lay-skin="switch" value="1" lay-text="权限+菜单|仅权限">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">图标</label>
        <div class="layui-input-block">
            <input type="text" name="icon" placeholder="仅在开启左侧菜单状态下有效,目前仅支持layui内置图标" autocomplete="off" class="layui-input" value="">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="id" value="{$data.id}" />
            <button class="layui-btn layui-btn-primary" lay-submit="" lay-filter="vaeform">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

{include file="admin/public/foot"}
<script>
    layui.config({
        base: '/static/admin_static/module/'
    }).use(['form','vae'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,$ = layui.$
            ,vae = layui.vae;

        //监听提交
        form.on('submit(vaeform)', function(data){
            vae.ajax({
                url:"{:url('admin/menu/add',['page'=>1])}",
                headers:{'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')},
                type:'post',
                data:data.field,
                success:function(res){
                    console.log(res);
                    layer.msg(res.msg);
                    if(res.code == 0){
                        vae.close();
                    }
                }
            })
            return false;
        });

    });
</script>

</body>
</html>